﻿using Forum.BaseController;
using Forum.Service.Interface;

namespace Forum.Controllers
{
    /// <summary>
    /// 博客网站通用信息
    /// </summary>
    [Route("Api/Blog")]
    public class BlogController : BaseController<IBlogService>
    {
        public BlogController(IBlogService defaultService, ILogger<BaseController<IBlogService>> logger) : base(defaultService, logger)
        {
        }

        /// <summary>
        /// 博客信息概况
        /// </summary>
        /// <returns></returns>
        // [Authorize]
        [HttpGet("[action]")]
        public ApiResponse<BlogOverviewResp> Overview()
        {
            return new ApiResponse<BlogOverviewResp>(DefaultService.Overview());
        }

        /// <summary>
        /// 获取置顶博客
        /// </summary>
        /// <returns></returns>
        [HttpGet("Top")]
        public ApiResponse<Post> GetTopOnePost()
        {
            return new ApiResponse<Post> { data = DefaultService.GetTopOnePost() };
        }

        /// <summary>
        /// 获取推荐博客
        /// </summary>
        /// <returns></returns>
        [HttpGet("Featured")]
        public ApiResponse<List<Post>> GetFeaturedPostRows()
        {
            return new ApiResponse<List<Post>>(DefaultService.GetFeaturedPosts());
        }

        /// <summary>
        /// 查询时间线
        /// </summary>
        /// <returns></returns>
        [HttpGet("TimeLine")]
        public ApiResponse<List<TimeLineResp>> GetTimeLines()
        {
            return new ApiResponse<List<TimeLineResp>>(DefaultService.GetTimeLines());
        }
    }
}
